<div class="dux-page-header uk-clearfix">
    <div class="page-title">
        <a class="uk-button uk-button-primary" href="{url('system/ConfigApi/index')}"> 接口列表</a>
    </div>
    <div class="page-action">
        <a class="uk-button uk-button-danger" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
    </div>
</div>

<div class="uk-margin-top">
    <div class="uk-card uk-card-default uk-card-small dux-panel">
        <div class="uk-card-header">基本信息</div>
        <div class="uk-card-body">
            <form class="dux-form uk-form  uk-form-horizontal  " data-dux="form-bind" method="post">
                <fieldset class="uk-fieldset">

                    <div class="uk-form-group">
                        <label class=" uk-form-label">接口类型</label>
                        <div class="uk-form-controls">
                            <select name="type" class="uk-select" data-dux="form-select" required>
                                <!--loop{$typeList as $key => $vo}-->
                                <option value="{$key}"
                                <!--if{ $key == $info['type'] }--> selected <!--{/if}-->
                                >{$vo.name}</option>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">名称</label>
                        <div class="uk-form-controls">
                            <input class="uk-input"  type="text" name="name" value="{$info.name}" placeholder="请输入接口名称" required>
                        </div>
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">接口标识</label>
                        <!--if{$info.label}-->
                        <div class="uk-form-controls uk-form-controls-text">
                            {$info.label}
                            <input class="uk-input"  type="hidden" name="label" value="{$info.label}">
                        </div>
                        <!--{else}-->
                        <div class="uk-form-controls">
                            <input class="uk-input"  type="text" name="label" value="{$info.label}" placeholder="请输入英文开头的英文数字标识" minlength="3" pattern="^\w+$" required>
                        </div>
                        <!--{/if}-->
                    </div>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">接口密钥</label>
                        <div class="uk-form-controls">
                            <input class="uk-input"  type="text" name="key" value="{$info.key}" placeholder="接口通讯密钥"  required>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">接口权限</label>
                        <div class="uk-form-controls">
                            <!--loop{$apiList as $app => $api}-->
                            <table class="uk-table  uk-table-responsive  uk-table-striped uk-table-hover uk-table-middle dux-table">
                                <thead>
                                <tr>
                                    <th colspan="2"><label><input type="checkbox"> {$app}</label></th>
                                </tr>
                                </thead>
                                <tbody>
                                <!--loop{$api as $method => $action}-->
                                <tr>
                                    <td width="120">
                                        <div class="checkbox"><label><input class="row" type="checkbox">
                                            {$method}</label>
                                        </div>
                                    </td>
                                    <td class="uk-grid">
                                        <!--loop{$action as $vo}-->
                                        <label>
                                            <!--if{ in_array($app.'.'.$method.'.'.$vo,(array)$info.rule) }-->
                                            <input  class="uk-checkbox"  name="rule[]" value="{$app}.{$method}.{$vo}" type="checkbox" checked="checked">
                                            <!--{else}-->
                                            <input  class="uk-checkbox"  name="rule[]" value="{$app}.{$method}.{$vo}" type="checkbox">
                                            <!--{/if}-->
                                            {$vo}</label>
                                        <!--{/loop}-->
                                    </td>
                                </tr>
                                <!--{/loop}-->
                                </tbody>
                            </table>
                            <!--{/loop}-->
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <div class="uk-form-controls">
                            <button class="uk-button uk-button-primary" type="submit">保存</button>
                        </div>
                    </div>

                </fieldset>
            </form>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('table').find('thead input[type=checkbox]').change(function () {
            if ($(this).prop('checked')) {
                $(this).parents('table').find("[type='checkbox']").prop("checked", true);
            } else {
                $(this).parents('table').find("[type='checkbox']").prop("checked", false);
            }
        });
        $('table').find('.row').change(function () {
            if ($(this).prop('checked')) {
                $(this).parents('tr').find("[type='checkbox']").prop("checked", true);
            } else {
                $(this).parents('tr').find("[type='checkbox']").prop("checked", false);
            }
        });
    });
</script>